<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<script type="text/javascript" charset="utf-8">
var admin_daloggl_datagrid;
var admin_daloggl_editRow = undefined;
var admin_daloggl_addRow = undefined;
var admin_daloggl_searchForm = undefined;
$(function(){
	admin_daloggl_searchForm = $('#admin_daloggl_searchForm').form();
	  $("#admin_daloggl_searchButton").bind('click', function(){   
		  
		  admin_daloggl_search(); 
	    }); 
	  $("#admin_daloggl_CleanSearchButton").bind('click', function(){   
		  
		  admin_daloggl_cleanSearch();
    }); 
		
	  admin_daloggl_datagrid=$('#admin_daloggl_datagrid').datagrid({
		url : '${pageContext.request.contextPath}/daLogAction!dataGrid.action',
		title:'档案调阅信息处理',
		iconCls:'icon-search',
		toolbar : '#admin_daloggl_toolbar',
		fit : true,
		border : false,
		striped:true,
		idField : 'id',
		rownumbers: true,		//显示行号
		fitColumns : true,		//显示横向滚动条
		pagination : true,
		pageSize : 20,
		pageList : [ 10,20, 30, 40, 50 ],
		sortName:'cjsj',
		sortOrder:'desc',
		columns : [[
					{title:'编号',field:'id',width:100,checkbox:true,},
					{title:'档案编号',field:'daId',width:100,sortable:true,},
					{title:'申请类别',field:'ztName',width:100,sortable:true,},
					{title:'申请人',field:'addUserName',width:100,sortable:true,},
					{title:'申请信息',field:'bz',width:100,sortable:true,},
					{title:'申请时间',field:'cjsj',width:100,sortable:true,}
					
				]],
				onLoadError:function(){
					$.messager.alert('提示', '请登录！', 'error');
				},
				onLoadSuccess:function(){
					// $('#daId2 input.validatebox-text').focus();
					 document.getElementById('daId1').focus();
					 $('#daId1').val('');
				}
			});
	//	  document.getElementById('daId1').focus();
		// $('#daId1').validatebox().next('span').find('input').focus();
		//console.info( $('#daId2 input.validatebox-text'));
		 // $("#daId2 input.validatebox-text").focus();

		});


		function admin_daloggl_search() {
				admin_daloggl_datagrid.datagrid('load', serializeObject(admin_daloggl_searchForm));
		}
		function admin_daloggl_cleanSearch() {
			admin_daloggl_datagrid.datagrid('load', {});
			admin_daloggl_searchForm.find('input').val('');
		}
		function admin_daloggl_gl() {
			var rows = admin_daloggl_datagrid.datagrid('getSelections');
			if (rows.length > 0) {
				$('#admin_daloggl_dialog').show();
					$('#admin_daloggl_dialog').dialog({
						collapsible: true,
						modal:true,
						buttons:[{
						text: '确认受理',
						iconCls: 'icon-ok',
						handler: function() { 
							var ids = [];
							$.messager.confirm('请确认', '您要操作当前所选项目？', function(r) {
								if (r) {
									for ( var i = 0; i < rows.length; i++) {
										ids.push(rows[i].id);
									}
									$.ajax({
										url : '${pageContext.request.contextPath}/daLogAction!edit.action',
										data : {
											ids : ids.join(','), bz1:$('#bz1').val()
										},
										type:'POST',
										dataType : 'json',
										success : function(r) {
											if (r.success) {
												admin_daloggl_datagrid.datagrid('unselectAll');
												$.messager.show({
													msg : r.msg,
													title : '成功'
												});
												$('#admin_daloggl_dialog').dialog('close');
												admin_daloggl_datagrid.datagrid('load');
											} else {
												admin_daloggl_datagrid.datagrid('load');
												$.messager.alert('错误', r.msg, 'error');
											}
										}
									});
								}
							});
						}},{
						text: '取消受理',
						iconCls: 'icon-no',
						handler: function() { 
							$('#admin_daloggl_dialog').dialog('close');
							admin_daloggl_datagrid.datagrid('unselectAll');
						}
						}
						]
				});
			} else {
				$.messager.alert('提示', '请选择要操作的记录！', 'error');
			}
		}
		
		function admin_daloggl_sl(){
			$.ajax({
				url : '${pageContext.request.contextPath}/daLogAction!fashEdit.action',
				data : {
					daId : $('#daId1').val()
				},
				type:'POST',
				dataType : 'json',
				success : function(r) {
					if (r.success) {
						admin_daloggl_datagrid.datagrid('unselectAll');
						$.messager.show({
							msg : r.msg,
							title : '成功'
						});
						$('#daId1').val('');
						admin_daloggl_datagrid.datagrid('load');
					} else {
						admin_daloggl_datagrid.datagrid('load');
						$.messager.alert('错误', r.msg, 'error');
					}
				}
			});

		}	
</script>
<div class="easyui-layout" fit="true">
	<div region="center" border="false" style="overflow: hidden;">
		<div id="admin_daloggl_toolbar" class="datagrid-toolbar" style="height: auto;display: none;">
			<fieldset>
				<legend>快速受理申请</legend>
					<table class="datagrid-toolbar" style="width: 100%;height: 100%;">
					<tr>
					<td>
					<label>档案编号:&nbsp;</label>  <input id="daId1" name="daId1" style="width:150px;" class="easyui-numberbox"  data-options="min:0,precision:0"></input>
					<a href='javascript:void(0);' onclick="admin_daloggl_sl();" class='easyui-linkbutton' data-options="iconCls:'icon-sqgl'">确认受理</a>
					</td>
					</tr>
					</table>
			</fieldset>
			<fieldset>
				<legend>筛选</legend>
					<form id="admin_daloggl_searchForm">
						<table class="admin_daloggl_searchForm datagrid-toolbar" style="width: 100%;height: 100%;">
						<tr>
						<td>
						<label>档案编号:&nbsp;</label><input name="daId" id="daId" />
						<label>档案状态:&nbsp;</label><input name="ztId" id="ztId" class='easyui-combobox' style="width:150px;" data-options="valueField:'id',textField:'zt',url:'${pageContext.request.contextPath}/ztAction!comboboxInfo.action',editable:false" />
						<label>申请时间:&nbsp;</label><input name="startCjsj" id="startCjsj" editable="fasle" class="easyui-datetimebox"/>&nbsp;至&nbsp;<input name="endCjsj" id="endCjsj" editable="fasle" class="easyui-datetimebox"/>
						<a href='javascript:void(0);' id="admin_daloggl_searchButton" class='easyui-linkbutton' data-options="iconCls:'icon-search'">查询</a>
						<a href='javascript:void(0);' id="admin_daloggl_CleanSearchButton" class='easyui-linkbutton' data-options="iconCls:'icon-cancel'">清空</a>
						</td>
						</tr>

						</table>
					</form>
			</fieldset>
			<div>
				<a class="easyui-linkbutton" iconCls="icon-add" onclick="admin_daloggl_gl();" plain="true" href="javascript:void(0);">同意申请</a>
				<a class="easyui-linkbutton" iconCls="icon-undo" onclick="admin_daloggl_datagrid.datagrid('unselectAll');" plain="true" href="javascript:void(0);">取消选中</a>
			</div>
		</div>
		<table id="admin_daloggl_datagrid"></table>
	</div>
</div>

<div id="admin_daloggl_dialog"  style="width:450px; height: 280px; display:none;" title="受理信息" iconCls="icon-tip">
		<table title="*您可以添加上自己的申请备注信息!" style="width: 100%;height: 100%;">
		<tr>
		<td>受理说明:</td><td><textarea rows="4" name="bz1" id="bz1" cols="30"></textarea></td>
		</tr>
		</table>
</div>